// 引入路径模块
const path = require('path')
const fs = require('fs')

// 当前文件所处的-目录- C:\Users\Administrator\PhpstormProjects\php入门\Nodejs\3路径模块
console.log(__dirname)

// 路径拼接 ../会抵消一个路径 即/c被抵消了
const pathStr1 = path.join('/a', '/b/c', '../', '/d', 'e')
console.log(pathStr1) //  \a\b\d\e

// 读取test.txt
fs.readFile(path.join(__dirname, 'test.txt'),'utf-8', (err, data) => {
  console.log(data)
})

// 读取上一层文件　Nodejs.txt
fs.readFile(path.join(__dirname, '../', 'Nodejs.txt'),'utf-8', (err, data) => {
  console.log(data)
})
